package com.topvision.controller.zwan;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.topvision.model.zwan.SessionFlow;
import com.topvision.service.zwan.SessionFlowService;
import com.topvision.util.PageUtils;
import com.topvision.util.Query;
import com.topvision.util.R;
import com.topvision.controller.AbstractController;

/**
 * 会话流量
 *
 * @author shengwm
 * @email 179653076@qq.com
 * @date 2018-05-25 13:32:59
 */
@RestController
@RequestMapping("zwan/sessionflow")
public class SessionFlowController extends AbstractController {
    @Autowired
    private SessionFlowService sessionFlowService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("zwan/sessionflow:list")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);

        List<SessionFlow> sessionFlowList = sessionFlowService.queryByParamAndPage(query);
        int total = sessionFlowService.queryByParamTotal(query);

        PageUtils pageUtil = new PageUtils(sessionFlowList, total, query.getLimit(), query.getPage());

        return R.success().put("page", pageUtil);
    }

    @RequestMapping("/findListByParam")
    @RequiresPermissions("zwan/sessionflow:list")
    public R findListByParam(@RequestParam Map<String, Object> params){

        List<SessionFlow> sessionFlowList = sessionFlowService.queryByParam(params);

        return R.success().put("sessionFlowList", sessionFlowList);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("zwan/sessionflow:info")
    public R info(@PathVariable("id") Long id){
        SessionFlow sessionFlow = sessionFlowService.queryObject(id);
        return R.success().put("sessionFlow", sessionFlow);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("zwan/sessionflow:save")
    public R save(@RequestBody SessionFlow sessionFlow){
		sessionFlowService.save(sessionFlow);
        return R.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("zwan/sessionflow:update")
    public R update(@RequestBody SessionFlow sessionFlow){
		sessionFlowService.update(sessionFlow);
        return R.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("zwan/sessionflow:delete")
    public R delete(@RequestBody Long[] ids){
		sessionFlowService.deleteBatch(ids);
        return R.success();
    }

}
